-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle footnote names that have been parsed into multiple nodes #311
Handle footnote names that have been parsed into multiple nodes #311
Conversation
05a4943
to
174ef95
Compare
174ef95
to
56aa94c
Compare
@kivikakk I think this one is ready for review. I think this PR also addresses #271, so added a test for that. You mentioned in #308 (comment) about using an enum for casing - the second commit is my attempt at that. Feel free to tweak as you desire. EDIT:
I didn't adjust the lexer at all, it mostly seems to be happening naturally. 🤷 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is excellent. 🤍 I'll run the fuzzer specifically on the footnote parsing for a few hours before merging.
src/strings.rs
Outdated
if Case::Preserve == casing { | ||
v.push(c); | ||
} else { | ||
v.push_str(&c.to_lowercase().to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also consider something like this in future, I think it's probably considered more "idiomatic Rust":
if Case::Preserve == casing { | |
v.push(c); | |
} else { | |
v.push_str(&c.to_lowercase().to_string()); | |
match casing { | |
Case::Preserve => v.push(c), | |
Case::DontPreserve => v.push_str(&c.to_lowercase().to_string()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks. I went ahead and applied this to the original commit and force pushed.
This ran into an issue with fuzzing almost immediately:
I've pushed a commit that includes the fuzzer for you to run, too. In this case, it looks like we presume the presence of a text node also implies it's non-empty, but isn't always. I've made the fix for this and hit another one:
This is getting thorny quickly, so I'll leave more to you. The repro case is as follows:
You can pipe this text into To run the fuzzer yourself, the following command runs it (on six cores):
You'll need to install a nightly Rust toolchain and |
0d6a5c9
to
014d341
Compare
into multiple nodes. For example `[^_foo]` gives `^`, `_`, and `foo`.
014d341
to
e80ed0e
Compare
So the |
Thanks so much, this looks great! |
For example
[^_foo]
gives^
,_
, andfoo
.Related
cmark-gfm
PR: github/cmark-gfm#229Related issue: #306